﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace coliseu.BussinessLayer
{
    public class LazerBL
    {
        private coliseuEntities cEntities;

        public LazerBL()
        {
            cEntities = new coliseuEntities(Properties.Settings.Default.conn_coliseu);
        }

        public List<area_lazer> selecionar()
        {
            return (from x in cEntities.area_lazer select x).ToList();
        }

        public List<area_lazer> selecionar(string descricao)
        {
            return (from x in cEntities.area_lazer where x.descricao.Contains(descricao) select x).ToList();
        }

        public void salvar(area_lazer b, string tipo)
        {

            if (tipo == "insert")
            {
                cEntities.AddToarea_lazer(b);
            }
            else
            {
                cEntities.area_lazer.ApplyCurrentValues(b);
            }
            cEntities.SaveChanges();
        }

        public void excluir(area_lazer b)
        {
            cEntities.area_lazer.DeleteObject(b);
            cEntities.SaveChanges();
        }
    }
}
